package com.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

public class TransactionManager {
	private Context context;
	private SQLiteDatabase db;
	private TransactionManager me;

	public TransactionManager(Context context) {
		super();
		this.context = context;
	}

	public TransactionManager(){
		if(me != null) me = new TransactionManager();
        	
		}
	public SQLiteDatabase start(){
		DataBaseHelper helper = new DataBaseHelper(context);
		db = helper.getWritableDatabase();
		db.beginTransaction();
		return db;
	}
	
	public SQLiteDatabase prepare(){
		return db;
	}

	public void commit() {
		db.setTransactionSuccessful();
		db.endTransaction();
		db.close();
	}

	public void rollback() {
		db.endTransaction();
		db.close();
	}
}